package com.example.boke.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author admin
 * @since 2021-05-12
 */
    public class Comment implements Serializable {

    private static final long serialVersionUID=1L;

      @TableId(value = "id", type = IdType.AUTO)
      private Long id;

    private Long blogId;

    private String nickname;

    private String email;

    private LocalDateTime createTime;

    private String content;

    private Long superiorId;

    @TableField(exist = false)
    //这一个是子级的评论
    private List<Comment> commentList;

    public Comment()
    {
      commentList = new ArrayList<>();
      this.createTime = LocalDateTime.now();
    }

  public static long getSerialVersionUID() {
    return serialVersionUID;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public Long getBlogId() {
    return blogId;
  }

  public void setBlogId(Long blogId) {
    this.blogId = blogId;
  }

  public String getNickname() {
    return nickname;
  }

  public void setNickname(String nickname) {
    this.nickname = nickname;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public LocalDateTime getCreateTime() {
    return createTime;
  }

  public void setCreateTime(LocalDateTime createTime) {
    this.createTime = createTime;
  }

  public String getContent() {
    return content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  public Long getSuperiorId() {
    return superiorId;
  }

  public void setSuperiorId(Long superiorId) {

    this.superiorId = superiorId;
  }

  public String getCreateDateTime() {

    String createtime = this.createTime+"";
    int length = createtime.length();
    return createtime.substring(0,length-7).replaceAll("T"," ");

  }

  public void addcomment(Comment comment)
  {
    this.commentList.add(comment);
  }

  public void addCommentList(List<Comment> comment)
  {
    this.commentList = comment;
  }

  public List<Comment> getCommentList() {
    return commentList;
  }

  public void setCommentList(List<Comment> commentList) {
    this.commentList = commentList;
  }

  @Override
  public String toString() {
    return "Comment{" +
            "id=" + id +
            ", blogId=" + blogId +
            ", nickname='" + nickname + '\'' +
            ", email='" + email + '\'' +
            ", createTime=" + createTime +
            ", content='" + content + '\'' +
            ", superiorId=" + superiorId +
            ", commentList=" + commentList +
            '}';
  }
}
